styleprovider: Change function prototype
authorBenjamin Otte <otte@redhat.com>
Sun, 25 Nov 2012 01:28:59 +0000 (02:28 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 25 Nov 2012 01:45:10 +0000 (02:45 +0100)
Make _gtk_style_provider_private_get_color() return a GtkCssValue (a
GtkCssColorValue to be exact) instead of GtkSymbolicColor.

With this, the symbolic color usage inside GTK is minimized.

gtk/gtkcsscolorvalue.c
gtk/gtkcssprovider.c
gtk/gtkmodifierstyle.c
gtk/gtksettings.c
gtk/gtkstylecascade.c
gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h
gtk/gtkstyleproperties.c
gtk/gtkstyleproviderprivate.c
gtk/gtkstyleproviderprivate.h

index ab7483ff0df59ca3105c59f2f174f3087782758f..5e6a7f0c028eeffa3882fc964a8421518e86a381 100644 (file)
@@ -161,14 +161,13 @@ _gtk_css_color_value_resolve (GtkCssValue             *color,
       return _gtk_css_value_ref (color->last_value);
     case COLOR_TYPE_NAME:
       {
-       GtkSymbolicColor *symbolic;
+       GtkCssValue *named;
 
-        symbolic = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
-
-       if (!symbolic)
+        named = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
+       if (named == NULL)
          return NULL;
 
-        value = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic), provider, current, current_deps, dependencies);
+        value = _gtk_css_color_value_resolve (named, provider, current, current_deps, dependencies);
       }
 
       break;
index 98eca494862a459b90f828d54512add0b306f24a..68bd3e5e8e655e5b8f6186001417033cbabfe01d 100644 (file)
 
 #include "gtkbitmaskprivate.h"
 #include "gtkcssarrayvalueprivate.h"
+#include "gtkcsscolorvalueprivate.h"
 #include "gtkcsskeyframesprivate.h"
 #include "gtkcssparserprivate.h"
 #include "gtkcsssectionprivate.h"
 #include "gtkcssselectorprivate.h"
 #include "gtkcssshorthandpropertyprivate.h"
 #include "gtkcssstylefuncsprivate.h"
-#include "gtksymboliccolor.h"
 #include "gtkstyleprovider.h"
 #include "gtkstylecontextprivate.h"
 #include "gtkstylepropertiesprivate.h"
@@ -1403,7 +1403,7 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
 
   priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                  (GDestroyNotify) g_free,
-                                                 (GDestroyNotify) gtk_symbolic_color_unref);
+                                                 (GDestroyNotify) _gtk_css_value_unref);
   priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
                                            (GDestroyNotify) g_free,
                                            (GDestroyNotify) _gtk_css_value_unref);
@@ -1479,7 +1479,7 @@ gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface)
   iface->get_style_property = gtk_css_provider_get_style_property;
 }
 
-static GtkSymbolicColor *
+static GtkCssValue *
 gtk_css_style_provider_get_color (GtkStyleProviderPrivate *provider,
                                   const char              *name)
 {
@@ -1838,7 +1838,7 @@ parse_import (GtkCssScanner *scanner)
 static gboolean
 parse_color_definition (GtkCssScanner *scanner)
 {
-  GtkSymbolicColor *symbolic;
+  GtkCssValue *color;
   char *name;
 
   gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
@@ -1862,8 +1862,8 @@ parse_color_definition (GtkCssScanner *scanner)
       return TRUE;
     }
 
-  symbolic = _gtk_css_symbolic_value_new (scanner->parser);
-  if (symbolic == NULL)
+  color = _gtk_css_color_value_parse (scanner->parser);
+  if (color == NULL)
     {
       g_free (name);
       _gtk_css_parser_resync (scanner->parser, TRUE, 0);
@@ -1874,7 +1874,7 @@ parse_color_definition (GtkCssScanner *scanner)
   if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
     {
       g_free (name);
-      gtk_symbolic_color_unref (symbolic);
+      _gtk_css_value_unref (color);
       gtk_css_provider_error_literal (scanner->provider,
                                       scanner,
                                       GTK_CSS_PROVIDER_ERROR,
@@ -1886,7 +1886,7 @@ parse_color_definition (GtkCssScanner *scanner)
       return TRUE;
     }
 
-  g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, symbolic);
+  g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, color);
 
   gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
   return TRUE;
@@ -2878,7 +2878,6 @@ gtk_css_provider_print_colors (GHashTable *colors,
                                GString    *str)
 {
   GList *keys, *walk;
-  char *s;
 
   keys = g_hash_table_get_keys (colors);
   /* so the output is identical for identical styles */
@@ -2887,14 +2886,12 @@ gtk_css_provider_print_colors (GHashTable *colors,
   for (walk = keys; walk; walk = walk->next)
     {
       const char *name = walk->data;
-      GtkSymbolicColor *symbolic = g_hash_table_lookup (colors, (gpointer) name);
+      GtkCssValue *color = g_hash_table_lookup (colors, (gpointer) name);
 
       g_string_append (str, "@define-color ");
       g_string_append (str, name);
       g_string_append (str, " ");
-      s = gtk_symbolic_color_to_string (symbolic);
-      g_string_append (str, s);
-      g_free (s);
+      _gtk_css_value_print (color, str);
       g_string_append (str, ";\n");
     }
 
index 5516d0ddf23ffb8d91b32759fe9e9cacd2cd720c..9c121915661566023ab3a29410070cef360aac2e 100644 (file)
@@ -122,7 +122,7 @@ gtk_modifier_style_provider_init (GtkStyleProviderIface *iface)
   iface->get_style_property = gtk_modifier_style_get_style_property;
 }
 
-static GtkSymbolicColor *
+static GtkCssValue *
 gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
                                        const char              *name)
 {
index 53ff44fb55002a7af59d59447ef0396f96ac6ad6..2ba95ad67041cd7ec439de43f50c5ab90ace70e6 100644 (file)
@@ -32,7 +32,6 @@
 #include "gtkprivate.h"
 #include "gtkcssproviderprivate.h"
 #include "gtkstyleproviderprivate.h"
-#include "gtksymboliccolor.h"
 #include "gtktypebuiltins.h"
 #include "gtkversion.h"
 
@@ -1460,7 +1459,7 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
 {
 }
 
-static GtkSymbolicColor *
+static GtkCssValue *
 gtk_settings_style_provider_get_color (GtkStyleProviderPrivate *provider,
                                        const char              *name)
 {
index 5061a060b8bb9f02ea7cc3b045bdd60f734b4068..a71a55e2a8e13d5e8e8d35678f299ab78e94ceab 100644 (file)
@@ -123,13 +123,13 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
   iface->get_style_property = gtk_style_cascade_get_style_property;
 }
 
-static GtkSymbolicColor *
+static GtkCssValue *
 gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
                              const char              *name)
 {
   GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
   GtkStyleCascadeIter iter;
-  GtkSymbolicColor *symbolic;
+  GtkCssValue *color;
   GtkStyleProvider *item;
 
   for (item = gtk_style_cascade_iter_init (cascade, &iter);
@@ -138,9 +138,9 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
     {
       if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
         {
-          symbolic = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
-          if (symbolic)
-            return symbolic;
+          color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
+          if (color)
+            return color;
         }
       else
         {
index ef7ecfdf4308e8202aa41f8e6d909fcee16b26fd..b74163ea1534a47a2d9512dbac0ea6b33cf05194 100644 (file)
@@ -2298,7 +2298,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
               else
                 g_value_init (&pcache->value, GDK_TYPE_COLOR);
 
-              if (_gtk_style_context_resolve_color (context, color, &rgba, NULL))
+              if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba, NULL))
                 {
                   if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
                     g_value_set_boxed (&pcache->value, &rgba);
@@ -2704,7 +2704,7 @@ gtk_style_context_get_junction_sides (GtkStyleContext *context)
 
 gboolean
 _gtk_style_context_resolve_color (GtkStyleContext    *context,
-                                  GtkSymbolicColor   *color,
+                                  GtkCssValue        *color,
                                   GdkRGBA            *result,
                                   GtkCssDependencies *dependencies)
 {
@@ -2714,7 +2714,7 @@ _gtk_style_context_resolve_color (GtkStyleContext    *context,
   g_return_val_if_fail (color != NULL, FALSE);
   g_return_val_if_fail (result != NULL, FALSE);
 
-  val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (color),
+  val = _gtk_css_color_value_resolve (color,
                                       GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
                                       _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
                                       GTK_CSS_DEPENDS_ON_COLOR,
@@ -2742,17 +2742,17 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
                                 const gchar     *color_name,
                                 GdkRGBA         *color)
 {
-  GtkSymbolicColor *sym_color;
+  GtkCssValue *value;
 
   g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
   g_return_val_if_fail (color_name != NULL, FALSE);
   g_return_val_if_fail (color != NULL, FALSE);
 
-  sym_color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
-  if (sym_color == NULL)
+  value = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
+  if (value == NULL)
     return FALSE;
 
-  return _gtk_style_context_resolve_color (context, sym_color, color, NULL);
+  return _gtk_style_context_resolve_color (context, value, color, NULL);
 }
 
 /**
index b48d1daf085725bde758d6788d21aeca9df174ee..0fd3f6bfe773c28649c8e7dc098731625a6f8d4a 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "gtkstylecontext.h"
 #include "gtkstyleproviderprivate.h"
-#include "gtksymboliccolor.h"
 #include "gtkbitmaskprivate.h"
 #include "gtkcssvalueprivate.h"
 
@@ -46,7 +45,7 @@ void           _gtk_style_context_queue_invalidate           (GtkStyleContext *c
 gboolean       _gtk_style_context_check_region_name          (const gchar     *str);
 
 gboolean       _gtk_style_context_resolve_color              (GtkStyleContext    *context,
-                                                              GtkSymbolicColor   *color,
+                                                              GtkCssValue        *color,
                                                               GdkRGBA            *result,
                                                               GtkCssDependencies *dependencies);
 void           _gtk_style_context_get_cursor_color           (GtkStyleContext    *context,
index 06407b62e6d76961ec71dead1ebc0a748c5f0b87..cb4c6ec877fdf007c00e1795a9ec8b1a2c3d3401 100644 (file)
@@ -284,11 +284,11 @@ gtk_style_properties_provider_init (GtkStyleProviderIface *iface)
 {
 }
 
-static GtkSymbolicColor *
+static GtkCssValue *
 gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
                                          const char              *name)
 {
-  return gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name);
+  return _gtk_symbolic_color_get_css_value (gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name));
 }
 
 static void
index 936f191190d183225417ddbb66c00be502201e62..7fb59d31c71282527b174b638182d392c37537a7 100644 (file)
@@ -44,7 +44,7 @@ _gtk_style_provider_private_default_init (GtkStyleProviderPrivateInterface *ifac
 
 }
 
-GtkSymbolicColor *
+GtkCssValue *
 _gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
                                        const char              *name)
 {
index 75a60493609a27633af78f00bba3e063077a959a..76e2a98f711deacea35f371c8feeb36ee4532ea5 100644 (file)
@@ -22,8 +22,7 @@
 #include "gtk/gtkcsskeyframesprivate.h"
 #include "gtk/gtkcsslookupprivate.h"
 #include "gtk/gtkcssmatcherprivate.h"
-#include <gtk/gtkenums.h>
-#include <gtk/gtksymboliccolor.h>
+#include "gtk/gtkcssvalueprivate.h"
 #include <gtk/gtktypes.h>
 
 G_BEGIN_DECLS
@@ -40,7 +39,7 @@ struct _GtkStyleProviderPrivateInterface
 {
   GTypeInterface g_iface;
 
-  GtkSymbolicColor *    (* get_color)           (GtkStyleProviderPrivate *provider,
+  GtkCssValue *         (* get_color)           (GtkStyleProviderPrivate *provider,
                                                  const char              *name);
   GtkCssKeyframes *     (* get_keyframes)       (GtkStyleProviderPrivate *provider,
                                                  const char              *name);
@@ -56,7 +55,7 @@ struct _GtkStyleProviderPrivateInterface
 
 GType                   _gtk_style_provider_private_get_type     (void) G_GNUC_CONST;
 
-GtkSymbolicColor *      _gtk_style_provider_private_get_color    (GtkStyleProviderPrivate *provider,
+GtkCssValue *           _gtk_style_provider_private_get_color    (GtkStyleProviderPrivate *provider,
                                                                   const char              *name);
 GtkCssKeyframes *       _gtk_style_provider_private_get_keyframes(GtkStyleProviderPrivate *provider,
                                                                   const char              *name);